package com.study.view.adapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.study.view.R;

import androidx.recyclerview.widget.RecyclerView;

/**
 * author : xujianhong
 * date   : 2022/11/8
 * desc   :
 * version: 1.0
 */
public class MRecyclerViewAdapter extends RecyclerView.Adapter<MRecyclerViewAdapter.ImageViewHolder> {

    @Override
    public ImageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_layout,parent,false);
        return new ImageViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ImageViewHolder holder, int position) {
        holder.nickName.setText(position+"Marry Js");
        Glide.with(holder.itemView.getContext()).load("https://c-ssl.duitang.com/uploads/blog/202107/09/20210709142454_dc8dc.jpeg").into(holder.imageView);
    }

    @Override
    public int getItemCount() {
        return 100;
    }

    class ImageViewHolder extends RecyclerView.ViewHolder{

        ImageView iv_avatar;
        ImageView imageView;
        TextView nickName;

        public ImageViewHolder(View itemView) {
            super(itemView);
            iv_avatar = itemView.findViewById(R.id.iv_avatar);
            imageView = itemView.findViewById(R.id.imageView);
            nickName = itemView.findViewById(R.id.nickName);
        }
    }
}
